home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / batch / TSBAT35.ARJ / PROMPT.TXT < prev    next >
Text File  |  1992-02-21  |  4KB  |  106 lines

  1. This file contains prompt tips by              (All rights reserved)
  2. ...................................................................
  3. Prof. Timo Salmi        
  4. Moderating at garbo.uwasa.fi anonymous ftp archives 128.214.87.1
  5. School of Business Studies, University of Vaasa, SF-65101, Finland
  6. Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun
  7.  
  8.  
  9. 1) If you have programs that can shell to dos it would be nice to
  10. know whether you currently are in a dos shell or not. Else you might
  11. call the same program again from the shell and eventually run out of
  12. memory. There is a rather straight-forward trick for this. Assume
  13. that your program is called prog.exe. You can always call the
  14. program from a batch, say pro.bat. Include the following lines in
  15. your batch:
  16.  
  17.   set _prompt=%prompt%
  18.   set prompt=%_prompt%[in shell or whatever text]
  19.   prog %1 %2 %3 %4 %5 %6 %7 %8 %9
  20.   set prompt=%_prompt%
  21.   set prompt=
  22.  
  23. The method will not work or will produce unexpected results if the
  24. program itself manipulates the prompt when shelling to Dos. Some
  25. (usually advanced) programs do.
  26.  
  27.  
  28. 2) A frequently asked question about ansi.sys is now does one use it
  29. to redefine keyboard keys. Here is an example which redefines the F1
  30. key invoke the directory "dir" command, the F2 key to invoke the
  31. "dir/w" command, and the F3 to type the Scandinavian letter ä.
  32.    prompt $e[0;59;"dir";13p
  33.    prompt $e[0;60;"dir/w";13p
  34.    prompt $e[0;61;"ä"p
  35.    prompt $p$g
  36.  
  37. The last line is needed to restore the prompt in its usual format
  38. (which I have as $p$g).
  39.  
  40. To cancel the definitions apply
  41.    prompt $e[0;59;;p
  42.    prompt $e[0;60;;p
  43.    prompt $e[0;61;;p
  44.    prompt $p$g
  45.  
  46. This system requires that you have ansi.sys loaded in your
  47. config.sys file
  48.    device=c:\dos\ansi.sys
  49.  
  50. Note that ansi.sys replacements like zansi.sys (which I normally use
  51. myself) do not have the key-redefinition feature. This has one
  52. advantages, that is protecting you against the so-called ansi bombs.
  53.  
  54. The 0;59 pair defines F1 because it is that key's scan code. To get
  55. the scan codes of the different keys you need either a scan code
  56. table or a program that gives the scan code of the key you have
  57. pressed. One such program is garbo.uwasa.fi:/pc/keyboard/keyb21.zip.
  58.  
  59.  
  60. 3) You can devise quite complicated ansi prompts to do flashy
  61. things although much of this is rather computer entertainment than
  62. serious usage. Let look at some examples
  63.  
  64. My ordinary prompt is the simple
  65.    prompt $p$g
  66. which displays the directory followed bu the > sign. Furthermore I
  67. use bright yellow on black, but for that I apply echo 
  68.  
  69. Let's build from that.
  70.    prompt $d $t$_$p$g
  71. Gives the date and the time on the first line ($d $t), then on the
  72. second ($_) gives the current directory ($p) and the > sign ($g).
  73.  
  74. Lets take a little more complicated example next:
  75.    prompt $e[s$e[1;69H$t$h$h$h$e[u$p$g
  76. This is of of the basic prompt tricks, and it puts the time in the
  77. upper right corner of the screen. First the current cursor postion
  78. is stored ($e[s); the cursor is moved to row 1, column 69 ($e[1;69H)
  79. the time is displayed ($t); the hundredths of a second are deleted
  80. ($h$h$h); the original cursor position is restored ($e[u); and
  81. finally the current directory and the > sign are displayed ($p$g).
  82.  
  83. The next obvious step is to display the time in some garish reverse.
  84. For the normal part of the prompt lets use my own default which is
  85. bright yellow on black ($e[40;33;1m).
  86.    prompt $e[s$e[1;69H$e[41;32;1m$t$e[40;33;1m$h$h$h$e[u$p$g
  87. The time is displayed in bright green on red ($e[41;32;1m).
  88.  
  89. The interpretation of the following prompt is left as an exercise:
  90.    prompt $e[s$e[H$e[43;30m$e[KDirectory $p $d $t $h$h$h$h $v
  91.           $e[40;33;1m$e[2;1H$e[K$e[u$p$g
  92. Note that you must have everything on one line only. The wrap here
  93. is just for readability.
  94.  
  95. One example of an "entertainment" prompt just to give the general
  96. idea:
  97.    prompt $e[s$_$e[40;37m██$e[34m██$e[37m████$_$e[34m████████
  98.           $e[40;37m$_██$e[34m██$e[37m████$e[40;33m $p$g
  99. Note that you must have everything on one line only. The wrap here
  100. is just for readability.
  101.  
  102.  
  103. 4) If you are having prombles you can "debug" your prompt by giving
  104. the set command in MsDos which displays your environment variables
  105. including the prompt variable.
  106.